import Splash from './splash'
import CacheRouter from './cacheRouter'
import SetAnimation from './setAnimation'

const MIXINS = {
  Splash,
  CacheRouter,
  SetAnimation
}

const append = function({components, key}) {
  const m = MIXINS[key]
  if(!m){
    const err = new Error('mixins not found')
    return console.error(err)
  }
  if(!components){
    const err = new Error('vueComponent is undefined')
    return console.error(err)
  }else if(!components.mixins)
    components.mixins = [m]
  else if(components.mixins instanceof Array){
    components.mixins.indexOf(m) === -1 && components.mixins.unshift(m)
  }
}

export default append
